package momo.app.multicast.presence.test;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Vector;

import momo.app.multicast.presence.PresenceCallback;
import momo.app.multicast.presence.PresenceMessage;
import momo.app.util.FileOutput;



public class PresenceCallbackImpl implements PresenceCallback {
    private String userName;
	
    public PresenceCallbackImpl(String userName) {
    	this.userName = userName;
    }
    
    public void setUserName(String userName) {
    	this.userName = userName;
    }
    
	public String getUserName() {
		return userName;
	}

	public HashMap<String, Integer> getVectorClock() {
        HashMap<String, Integer> hashmap = new HashMap<String, Integer>();
        hashmap.put(userName, 0);
        return hashmap;
	}

	public int getVersion() {
		return 0;
	}

	public void onReceivePresenceResult(Vector<PresenceMessage> result) {
		SimpleDateFormat format = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss,SSS]");
		System.out.println(format.format(new Date()) + " Receive prensence result: " + result.toString());
		FileOutput.getInstance().logToFile("presence.log", "Receive prensence result: " + result.toString());
	}

	public void onInitiatePresence() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onConnected() {
		// TODO Auto-generated method stub
		
	}

}
